/*
 This file 'zdwxy_1' is part of Firebird Integrated Solution 1.0

 Copyright (c) 2020 Lincong

 Contact:  
        Email: lincong1987@gmail.com

        QQ: 159257119
 
 See Usage at http://www.jplatformx.com/firebird

 Create date: 2020-06-14 20:49
 */

define(function (require, exports, module) {

	require("../model/Chart");

	var ArrayUtils = require("../assets/ArrayUtils");

	var id = "zdwxy_8_chart_1";

	Firebird.define(id, {
		extend: "Chart",
		setValue: function (data) {

			/**
			 * 3个饼图的数据 为 data = [ 饼1数组, 饼2数组, 饼3数组 ]
			 * @type {*[][]}
			 */
			this.data = data = [
				[
					{
						name: "炼化",
						value: 10
					}, {
					name: "销售",
					value: 10
				}, {
					name: "XXX",
					value: 10
				}, {
					name: "OOO",
					value: 10
				}
				], [
					{
						name: "一级",
						value: 10
					}, {
						name: "二级",
						value: 10
					}, {
						name: "三级",
						value: 10
					}, {
						name: "四级",
						value: 10
					}
				], [
					{
						name: "红色预警",
						value: 10
					}, {
						name: "橙色预警",
						value: 10
					}, {
						name: "黄色预警",
						value: 10
					}, {
						name: "蓝色预警",
						value: 10
					}
				]

			];

			var color = [
				Chart.linearGradient("rgba(173, 45, 45, 1)", "rgba(216, 74, 86, 1)"),
				Chart.linearGradient("rgba(207, 122, 18, 1)", "rgba(229, 167, 71, 1)"),
				Chart.linearGradient("rgba(255, 208, 106, 1)", "rgba(173, 156, 0, 1)"),
				Chart.linearGradient("rgba(59, 81, 255, 1)", "rgba(88, 138, 255, 1)")
			];

			var option = {

				color: color,

				title: [
					{
						text: "各版块今日预警情况",
						left: "16.7%",
						top: 40,
						textAlign: 'center',
						textStyle: {
							color: "rgba(82, 255, 253, 1)",
							fontSize: 16
						}
					}, {
						text: "今日预警重大危险源级别分布",
						left: "50%",
						top: 40,
						textAlign: 'center',
						textStyle: {
							color: "rgba(82, 255, 253, 1)",
							fontSize: 16
						}
					}, {
						text: "今日预警等级分布",
						left: "83.3%",
						top: 40,
						textAlign: 'center',
						textStyle: {
							color: "rgba(82, 255, 253, 1)",
							fontSize: 16
						}
					}
				],

				grid: {
					top: 0,
					left: 0,
					right: 0,
					bottom: 0
				},


				tooltip: {
					trigger: 'axis',
					axisPointer: {
						type: 'shadow',
						label: {
							show: true,
							backgroundColor: '#333'
						}
					}
				},

				series: [

					{
						radius: [30, 60],
						center: ["16.7%", 190],
						type: 'pie',
						label: {
							width: 80,
							rich: {},
							normal: {
								show: true,
								formatter: "{b}\n{c}",
								textStyle: {
									color: "#fff",
									fontSize: 16,
								}, // position: 'outside'
							},
							emphasis: {
								show: true
							}
						},
						labelLine: {
							normal: {
								show: true, // length: 30,
								// length2: 55
							},
							emphasis: {
								show: true
							}
						},
						data: data[0].map(function (node, index) {
							 
							// node.label = {
							// 	width: 80,
							// 	normal: {
							// 		show: true,
							// 		formatter: "{b}\n{c}",
							// 		color: color[index],
							// 		textStyle: {
							// 			fontSize: 16,
							// 		}
							// 	},
							// 	emphasis: {
							// 		show: true
							// 	}
							// };
							
							return node;
						})

					},

					{
						radius: [30, 60],
						center: ["50%", 190],
						type: 'pie',
						label: {
							width: 80,
							rich: {},
							normal: {
								show: true,
								formatter: "{b}\n{c}",
								textStyle: {
									color: "#fff",
									fontSize: 16,
								}, // position: 'outside'
							},
							emphasis: {
								show: true
							}
						},
						labelLine: {
							normal: {
								show: true, // length: 30,
								// length2: 55
							},
							emphasis: {
								show: true
							}
						},
						data: data[1].map(function (node, index) {
							return node;
						})

					},

					{
						radius: [30, 60],
						center: ["83.3%", 190],
						type: 'pie',
						label: {
							width: 80,
							rich: {},
							normal: {
								show: true,
								formatter: "{b}\n{c}",
								textStyle: {
									color: "#fff",
									fontSize: 16,
								}, // position: 'outside'
							},
							emphasis: {
								show: true
							}
						},
						labelLine: {
							normal: {
								show: true, // length: 30,
								// length2: 55
							},
							emphasis: {
								show: true
							}
						},
						data: data[2].map(function (node, index) {
							return node;
						})

					},
				]
			};

			this.clear();
			this.setOption(option, !0);
		},
	});

	module.exports = Firebird.create(id, {id: id});
});